package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.FirstAddressBean;
import com.lwj.liwanjia.impl.FirstAddressView;
import com.lwj.liwanjia.model.FirstAddressModel;

import rx.Subscriber;


/**
 * Created by Administrator on 2017/10/10.
 */

public class FirstAddressPresenter {
    private FirstAddressView firstAddressView;
    private FirstAddressModel firstAddressModel;

    public FirstAddressPresenter(FirstAddressView firstAddressView) {
        this.firstAddressView = firstAddressView;
        firstAddressModel = new FirstAddressModel();
    }

    public void firstAddress(String token, String consigneeId) {
        if (firstAddressView != null) {
            firstAddressModel.firstAddress(token, consigneeId, new Subscriber<FirstAddressBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    firstAddressView.showError((Exception) e);
                }

                @Override
                public void onNext(FirstAddressBean firstAddressBean) {
                    firstAddressView.firstAddress(firstAddressBean);
                }
            });
        }
    }
}
